"""
进程模型
"""
from pydantic import BaseModel
from datetime import datetime
from typing import Optional

class ProcessBase(BaseModel):
    """进程基础模型"""
    machine_id: int
    pid: int
    name: str
    cpu: float = 0.0
    memory: int = 0
    user: Optional[str] = None
    status: Optional[str] = "running"
    port: Optional[str] = None

class ProcessCreate(ProcessBase):
    """创建进程模型"""
    collected_at: Optional[datetime] = None

class ProcessUpdate(ProcessBase):
    """更新进程模型"""
    pass

class ProcessInDBBase(ProcessBase):
    """数据库进程基础模型"""
    id: int
    collected_at: datetime
    created_at: datetime

    class Config:
        from_attributes = True

class Process(ProcessInDBBase):
    """进程信息"""
    pass